/*
 * 2013-9-2:下午2:03:29
 * Keen
 */
package com.razdev.mtk.string;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

/**
 * 封装的String类型<br>
 * 2013-9-2:下午2:03:29
 * 
 * @author Keen<br>
 */
public class MString extends StringUtils implements IMString {
	private String s;

	/**
	 * constructor
	 * 
	 * @param s
	 *          src String s
	 */
	public MString(String s) {
		this.s = s;
	}

	/**
	 * constructor without args
	 */
	public MString() {
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	public Integer length() {
		return s.length();
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	public IMString merge(Integer strategy, String a, String b) {
		switch (strategy) {
		case 2:
			return new MString(a + b);
		case 4:
			return new MString(b + a);
		default:
			return null;
		}
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	public IMString merge(String a, String b) {
		return this.merge(MStringMergeStrategy.APPEND, a, b);
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	public List<char[]> toCharList() {
		return Arrays.asList(s.toCharArray());
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	public char[] toCharArray() {
		return s.toCharArray();
	}

	/*
	 * TODO fill method description
	 * <br>
	 * 2013-9-16:下午10:05:02<br>
	 * This method is implementate by: Keen 
	 */
	@Override
	public String toString() {
		return s;
	}
}
